
//
//  DINGBottomView.swift
//  0730Microblog
//
//  Created by ding on 15/8/6.
//  Copyright © 2015年 ding. All rights reserved.
//

import UIKit

class DINGBottomView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor.lightGrayColor()
        setupBottomViewUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupBottomViewUI() {
        addSubview(reposts_countBtn)
        addSubview(comments_countBtn)
        addSubview(attitudes_countBtn)
        
        //MARK: - 懒加载控件
        reposts_countBtn.translatesAutoresizingMaskIntoConstraints = false
        addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-0-[targetView]-0-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["targetView" : reposts_countBtn]))
        addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-0-[targetView]-0-[rightReference]", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["targetView" : reposts_countBtn, "rightReference" : comments_countBtn]))
        addConstraint(NSLayoutConstraint(item: reposts_countBtn, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: comments_countBtn, attribute: NSLayoutAttribute.Width, multiplier: 1.0, constant: 0))
        
        comments_countBtn.translatesAutoresizingMaskIntoConstraints = false
        addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-0-[targetView]-0-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["targetView" : comments_countBtn]))
        addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:[leftReference]-0-[targetView]-0-[rightReference]", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["leftReference" : reposts_countBtn, "targetView" : comments_countBtn, "rightReference" : attitudes_countBtn]))
        addConstraint(NSLayoutConstraint(item: comments_countBtn, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: attitudes_countBtn, attribute: NSLayoutAttribute.Width, multiplier: 1.0, constant: 0))
        
        attitudes_countBtn.translatesAutoresizingMaskIntoConstraints = false
        addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-0-[targetView]-0-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["targetView" : attitudes_countBtn]))
        addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:[leftReference]-0-[targetView]-0-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["targetView" : attitudes_countBtn, "leftReference" : comments_countBtn]))
        
    }
    
    private lazy var reposts_countBtn: UIButton = {
        let repostBtn = UIButton()
        repostBtn.setBackgroundImage(UIImage(named: "timeline_card_middle_background"), forState: UIControlState.Normal)
        repostBtn.setBackgroundImage(UIImage(named: "timeline_card_middle_background_highlighted"), forState: UIControlState.Highlighted)
        
        repostBtn.setImage(UIImage(named: "timeline_icon_retweet"), forState: UIControlState.Normal)
        repostBtn.setTitle(" 转发", forState: UIControlState.Normal)
//        repostBtn.tintColor = UIColor.blackColor()
//        repostBtn.titleLabel?.tintColor = UIColor.purpleColor()
//        repostBtn.titleLabel?.textColor = UIColor.purpleColor()
        repostBtn.setTitleColor(UIColor.purpleColor(), forState: UIControlState.Normal)
        return repostBtn
    }()
    private lazy var comments_countBtn: UIButton = {
        let commentBtn = UIButton()
        commentBtn.setBackgroundImage(UIImage(named: "timeline_card_middle_background"), forState: UIControlState.Normal)
        commentBtn.setBackgroundImage(UIImage(named: "timeline_card_middle_background_highlighted"), forState: UIControlState.Highlighted)
        
        commentBtn.setImage(UIImage(named: "timeline_icon_comment"), forState: UIControlState.Normal)
        commentBtn.setTitle(" 评论", forState: UIControlState.Normal)
//        commentBtn.tintColor = UIColor.blackColor()
//        commentBtn.titleLabel?.tintColor = UIColor.redColor()
//        commentBtn.titleLabel?.textColor = UIColor.redColor()
        commentBtn.setTitleColor(UIColor.purpleColor(), forState: UIControlState.Normal)
        return commentBtn
    }()
    private lazy var attitudes_countBtn: UIButton = {
        let attitudeBtn = UIButton()
        attitudeBtn.setBackgroundImage(UIImage(named: "timeline_card_middle_background"), forState: UIControlState.Normal)
        attitudeBtn.setBackgroundImage(UIImage(named: "timeline_card_middle_background_highlighted"), forState: UIControlState.Highlighted)
        
        attitudeBtn.setImage(UIImage(named: "timeline_icon_unlike"), forState: UIControlState.Normal)
        attitudeBtn.setTitle(" 点赞", forState: UIControlState.Normal)
//        attitudeBtn.tintColor = UIColor.blackColor()
//        attitudeBtn.titleLabel?.tintColor = UIColor.yellowColor()
//        attitudeBtn.titleLabel?.textColor = UIColor.yellowColor()
        attitudeBtn.setTitleColor(UIColor.purpleColor(), forState: UIControlState.Normal)
        return attitudeBtn
    }()
    
    

}
